The LCD understands a number of commands which are designed to be used on a range of different configurations of panel. We do not have the time or the space to go into these in any detail right now, although a data sheet for the commands is available for reference. Instead I will just give the commands which we need to use to set the panel up and make it ready for action.

I constructed the commands by creating the bit patterns from the data sheet and then converting them into hex for inclusion in the program.

The function setup_lcd sends all five bytes of the lcd_init array and then calls the clear function to clear the display and make it ready for use.

Note also that I set up the hardware in this function, being careful not to change the settings on bits of PORTB which I am not using. I also perform a short delay to let the LCD settle if we are being called just after the power going on.

Load and run Exercise 5.1 and see how it displays a message on the LCD panel.